﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using LogManager.Base;
using LogManager.Base.Data;
using LogManager.Windows.Data;

namespace LogManager.Models
{
    public class CsvLog : BaseLog
    {
        private IEventTypeService _typeService;
        private IDictionary<string, object> _properties;
        private Lazy<IEventExportService> _exportService;

        public CsvLog(IEventTypeService typeService)
        {
            _typeService = typeService;
        }

        public override void Initialize(string serverName, string logName, string typeId)
        {
            _properties = new Dictionary<string,object>();
            _exportService = new Lazy<IEventExportService>(() => new CsvExportService(serverName, logName,Path,_typeService));
            base.Initialize(serverName, logName, typeId);
        }

        public override IEventExportService ExportService
        {
            get { return _exportService.Value; }
            protected set
            {
                throw new NotSupportedException();
            }
        }

        public string Path { get { return (string)_properties.GetValueOrDefault("path", null); } set { _properties["path"] = value; }}

        public override IDictionary<string, object> Properties
        {
            get { return _properties; }
        }
        
    }
}